#pragma once
#include "core.h"
#include <QString>
#include <QIODevice>
#include <QFile>
#include "strings/BaseString.h"

class S_CORE_EXPORT FileSys
{
public:
    static FileSys* instance();
    //directory
    QString runRootDir() const;
    QString appCfgDir() const;//file in this directory should not be changed!
    QString logDir() const;
    QString userCfgDir() const;
    QString tmpDir() const;
    bool createFile(const QString& fullFileName, QIODevice::OpenModeFlag flag, QFile*& file) const;
    bool closeFile(QFile* file) const;
    int64_t getFileSize(QFile* file) const;
    int64_t readFile(QFile* file, char *data, int64_t maxlen);
    int copyFile(const char* src, const char* des);
    bool removeFile(const QString& fullFileName) const;
    bool isFileExist(const QString& fullFileName) const;
    bool isFileWritable(const QString& fullFileName) const;
    bool makePathExist(const QString& path) const;
    qb::base::BaseString getSlashPath(const char* path);
    void		makeSlashPath(qb::base::BaseString& path);

    void setUserId(const QString v) { m_userId = v; }

private:
    FileSys();

    QString     m_exeDir;
    QString     m_appName;
    QString     m_userId;
};
